using RxjhServer.HelperTools;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;

namespace RxjhServer.DbClss
{
	public class RxjhClass
	{
		private static ItmesIDClass ItmeId = new ItmesIDClass();

		public static List<Chou_jiang_item> chou_Jiang_Items = null;

		public static void 设置账号在线状态(string uid, int online)
		{
			DBA.ExeSqlCommand($"UPDATE  TBL_ACCOUNT  SET  FLD_ONLINE={online}  WHERE  FLD_ID='{uid}'", "rxjhaccount");
		}

		public static List<TBL_假人出售物品> 获取假人商店物品()
		{
			Form1.WriteLine(2, "假人出售物品数据完成   ");
			try
			{
				DataTable dBToDataTable = DBA.GetDBToDataTable("Select * from TBL_假人出售物品");
				if (dBToDataTable != null)
				{
					if (dBToDataTable.Rows.Count != 0)
					{
						List<TBL_假人出售物品> list = new List<TBL_假人出售物品>();
						if (dBToDataTable.Rows.Count >= 1)
						{
							for (int i = 0; i < dBToDataTable.Rows.Count; i++)
							{
								TBL_假人出售物品 tBL_假人出售物品 = new TBL_假人出售物品();
								tBL_假人出售物品.Id = (int)dBToDataTable.Rows[i]["Id"];
								tBL_假人出售物品.ItemPid = (int)dBToDataTable.Rows[i]["ItemPid"];
								tBL_假人出售物品.ItemPrice = (int)dBToDataTable.Rows[i]["ItemPrice"];
								tBL_假人出售物品.FLD_MAGIC0 = (int)dBToDataTable.Rows[i]["FLD_MAGIC0"];
								tBL_假人出售物品.FLD_MAGIC1 = (int)dBToDataTable.Rows[i]["FLD_MAGIC1"];
								tBL_假人出售物品.FLD_MAGIC2 = (int)dBToDataTable.Rows[i]["FLD_MAGIC2"];
								tBL_假人出售物品.FLD_MAGIC3 = (int)dBToDataTable.Rows[i]["FLD_MAGIC3"];
								tBL_假人出售物品.FLD_MAGIC4 = (int)dBToDataTable.Rows[i]["FLD_MAGIC4"];
								tBL_假人出售物品.FLD_最少数量 = (int)dBToDataTable.Rows[i]["FLD_最少数量"];
								tBL_假人出售物品.FLD_最大数量 = (int)dBToDataTable.Rows[i]["FLD_最大数量"];
								tBL_假人出售物品.ItemTitle = dBToDataTable.Rows[i]["ItemTitle"].ToString();
								list.Add(tBL_假人出售物品);
							}
						}
						dBToDataTable?.Dispose();
						return list;
					}
					dBToDataTable.Dispose();
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
			}
			return null;
		}

		public static int 假人GetUserName(string string_0)
		{
			DataTable dBToDataTable = DBA.GetDBToDataTable("SELECT  FLD_NAME  FROM  TBL_人物数据  WHERE  FLD_NAME=@name", new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, string_0)
			});
			if (dBToDataTable == null)
			{
				return -1;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				dBToDataTable.Dispose();
				return 1;
			}
			dBToDataTable.Dispose();
			return -1;
		}

		public static string 得到账号下第一个人物名字(string userID)
		{
			DataTable dBToDataTable = DBA.GetDBToDataTable("SELECT  *  FROM  TBL_人物数据  WHERE  FLD_ID  =  @name", new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 500, userID)
			});
			if (dBToDataTable == null)
			{
				return "";
			}
			if (dBToDataTable.Rows.Count != 0)
			{
				return dBToDataTable.Rows[0]["FLD_NAME"].ToString();
			}
			return "";
		}

		public static string GetRandomString()
		{
			byte[] array = new byte[4];
			new RNGCryptoServiceProvider().GetBytes(array);
			Random random = new Random(BitConverter.ToInt32(array, 0));
			string text = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
			return text.Substring(random.Next(0, text.Length - 1), 1);
		}

		public static string md5(string strmm)
		{
			MD5 mD = new MD5CryptoServiceProvider();
			byte[] value = mD.ComputeHash(Encoding.ASCII.GetBytes(strmm));
			return BitConverter.ToString(value).Replace("-", "").ToLower();
		}

		public static long GetDBItmeId()
		{
			return ItmeId.AcquireBuffer();
		}

		public static DataTable 得到势力战数据()
		{
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.Int, 4, 0)
			};
			DataTable dataTable = SqlDBA.RunProcc(new SqlConnection(DBA.getstrConnection(null)), "LOAD_EVENTTOP", prams);
			if (dataTable != null)
			{
				if (dataTable.Rows.Count > 0)
				{
					return dataTable;
				}
				dataTable.Dispose();
			}
			return null;
		}

		public static void 保存势力战数据(EventTopClass EventTop)
		{
			SqlParameter[] prams = new SqlParameter[6]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.NVarChar, 30, EventTop.人物名),
				SqlDBA.MakeInParam("@bpname", SqlDbType.NVarChar, 30, EventTop.帮派),
				SqlDBA.MakeInParam("@zx", SqlDbType.NVarChar, 30, EventTop.势力),
				SqlDBA.MakeInParam("@level", SqlDbType.Int, 4, EventTop.等级),
				SqlDBA.MakeInParam("@killnum", SqlDbType.Int, 4, EventTop.杀人数),
				SqlDBA.MakeInParam("@deathnum", SqlDbType.Int, 4, EventTop.死亡数)
			};
			SqlDBA.RunProc(new SqlConnection(DBA.getstrConnection(null)), "INSERT_EVENTTOP_LOGS", prams);
		}

		public static void 变更门服(int 帮派id, int 门服字, int 门服颜色)
		{
			string sqlCommand = string.Format("UPDATE TBL_帮派数据 SET 门服字={1},门服颜色={2} WHERE ID='{0}'", 帮派id, 门服字, 门服颜色);
			DBA.ExeSqlCommand(sqlCommand);
		}

		public static void msglog(string userid, string username, string tousername, string msg, int msgType)
		{
			string sqlCommand = $"INSERT INTO MsgLog (userid,username,ToUserName,msg,msgType) VALUES ('{userid}','{username}','{tousername}','{msg}',{msgType})";
			DBA.ExeSqlCommand(sqlCommand);
		}

		public static void 百宝记录(string UserId, string UserName, double 物品ID, string 物品名, int 物品数量, int 元宝数)
		{
			string sqlCommand = $"INSERT INTO 百宝记录 (UserId,UserName,物品ID,物品名,物品数量,元宝数) VALUES ('{UserId}','{UserName}','{物品ID}','{物品名}',{物品数量},{元宝数})";
			DBA.ExeSqlCommand(sqlCommand);
		}

		public static void 登陆记录(string UserId, string UserName, string UserIp, string 类型)
		{
			if (World.登陆记录 == 1)
			{
				string sql = "INSERT INTO 登陆记录 (UserId,UserName,UserIp,类型) VALUES (@UserId,@UserName,@UserIp,@类型)";
				SqlParameter[] prams = new SqlParameter[4]
				{
					SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
					SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
					SqlDBA.MakeInParam("@UserIp", SqlDbType.VarChar, 30, UserIp),
					SqlDBA.MakeInParam("@类型", SqlDbType.VarChar, 30, 类型)
				};
				DbPoolClass dbPoolClass = new DbPoolClass();
				dbPoolClass.Conn = DBA.getstrConnection(null);
				dbPoolClass.Prams = prams;
				dbPoolClass.Sql = sql;
				dbPoolClass.Type = 1;
				World.SqlPool.Enqueue(dbPoolClass);
			}
		}

		public static void 掉落记录(string UserId, string UserName, string 线路, double 全局ID, string 物品, string 掉落源, string 类型)
		{
			if (World.记录掉落)
			{
				string sql = "INSERT INTO 掉落记录 (UserId,UserName,线路,全局ID,物品,掉落源,类型) VALUES (@UserId,@UserName,@线路,@全局ID,@物品,@掉落源,@类型)";
				SqlParameter[] prams = new SqlParameter[7]
				{
					SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
					SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
					SqlDBA.MakeInParam("@线路", SqlDbType.VarChar, 30, 线路),
					SqlDBA.MakeInParam("@全局ID", SqlDbType.VarChar, 30, 全局ID),
					SqlDBA.MakeInParam("@物品", SqlDbType.VarChar, 30, 物品),
					SqlDBA.MakeInParam("@掉落源", SqlDbType.VarChar, 30, 掉落源),
					SqlDBA.MakeInParam("@类型", SqlDbType.VarChar, 30, 类型)
				};
				DbPoolClass dbPoolClass = new DbPoolClass();
				dbPoolClass.Conn = DBA.getstrConnection(null);
				dbPoolClass.Prams = prams;
				dbPoolClass.Sql = sql;
				dbPoolClass.Type = 1;
				World.SqlPool.Enqueue(dbPoolClass);
			}
		}

		public static DataTable get首爆记录(int 物品属性, string 分区)
		{
			DataTable dBToDataTable = DBA.GetDBToDataTable($"select * from [首爆石头记录] where 物品属性={物品属性} and 分区='{分区}'  order by  newDate");
			return null;
		}

		public static void set首爆石头记录(string UserId, string UserName, int 物品属性, string 物品名字, string 分区)
		{
			string sql = "insert into[首爆石头记录](Userid, UserName, 物品属性, 物品名字) VALUES(@Userid,@UserName,@物品属性,@物品名字, '" + 分区 + "')";
			SqlParameter[] prams = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
				SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
				SqlDBA.MakeInParam("@物品属性", SqlDbType.Int, 0, 物品属性),
				SqlDBA.MakeInParam("@物品名字", SqlDbType.VarChar, 200, 物品名字)
			};
			World.SqlPool.Enqueue(new DbPoolClass
			{
				Conn = DBA.getstrConnection(null),
				Prams = prams,
				Sql = sql,
				Type = 1
			});
		}

		public static DataTable get首爆记录表(int 物品ID, string 分区)
		{
			DataTable dBToDataTable = DBA.GetDBToDataTable(string.Format($"select * from [首爆物品记录] where 物品ID={物品ID} and 分区='{分区}'  order by  newDate"));
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static void set首爆记录表(string UserId, string UserName, int 物品ID, string 物品名字, string 分区)
		{
			string sql = "insert into[首爆物品记录](Userid, UserName, 物品ID, 物品名字,分区) VALUES(@Userid,@UserName,@物品ID,@物品名字,'" + 分区 + "')";
			SqlParameter[] prams = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
				SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
				SqlDBA.MakeInParam("@物品ID", SqlDbType.Int, 0, 物品ID),
				SqlDBA.MakeInParam("@物品名字", SqlDbType.VarChar, 200, 物品名字)
			};
			World.SqlPool.Enqueue(new DbPoolClass
			{
				Conn = DBA.getstrConnection(null),
				Prams = prams,
				Sql = sql,
				Type = 1
			});
		}

		public static void 物品记录(string UserId, string UserName, string ToUserId, string ToUserName, double 全局ID, int 物品ID, string 物品名, int 物品数量, string 物品属性, int 钱数, string 类型)
		{
			if (World.物品记录 == 1)
			{
				string sql = "INSERT INTO 物品记录 (UserId,UserName,ToUserId,ToUserName,全局ID,物品ID,物品名,物品数量,物品属性,钱数,类型) VALUES (@UserId,@UserName,@ToUserId,@ToUserName,@全局ID,@物品ID,@物品名,@物品数量,@物品属性,@钱数,@类型)";
				SqlParameter[] prams = new SqlParameter[11]
				{
					SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
					SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
					SqlDBA.MakeInParam("@ToUserId", SqlDbType.VarChar, 30, ToUserId),
					SqlDBA.MakeInParam("@ToUserName", SqlDbType.VarChar, 30, ToUserName),
					SqlDBA.MakeInParam("@全局ID", SqlDbType.VarChar, 30, 全局ID),
					SqlDBA.MakeInParam("@物品ID", SqlDbType.VarChar, 30, 物品ID),
					SqlDBA.MakeInParam("@物品名", SqlDbType.VarChar, 30, 物品名),
					SqlDBA.MakeInParam("@物品数量", SqlDbType.Int, 4, 物品数量),
					SqlDBA.MakeInParam("@物品属性", SqlDbType.VarChar, 100, 物品属性),
					SqlDBA.MakeInParam("@钱数", SqlDbType.Int, 4, 钱数),
					SqlDBA.MakeInParam("@类型", SqlDbType.VarChar, 10, 类型)
				};
				DbPoolClass dbPoolClass = new DbPoolClass();
				dbPoolClass.Conn = DBA.getstrConnection(null);
				dbPoolClass.Prams = prams;
				dbPoolClass.Sql = sql;
				dbPoolClass.Type = 1;
				World.SqlPool.Enqueue(dbPoolClass);
			}
		}

		public static void 帮战最后奖励(int 帮派ID, int sl)
		{
			switch (sl)
			{
			case 1:
			{
				string sqlCommand3 = $"UPDATE TBL_帮派数据 SET 胜=胜+2 WHERE ID='{帮派ID}'";
				DBA.ExeSqlCommand(sqlCommand3);
				break;
			}
			case -1:
			{
				string sqlCommand2 = $"UPDATE TBL_帮派数据 SET 败=败+1,胜=胜+1 WHERE ID='{帮派ID}'";
				DBA.ExeSqlCommand(sqlCommand2);
				break;
			}
			case 0:
			{
				string sqlCommand = $"UPDATE TBL_帮派数据 SET 平=平+1 WHERE ID='{帮派ID}'";
				DBA.ExeSqlCommand(sqlCommand);
				break;
			}
			}
		}

		public static void 申请门徽(int 帮派id, byte[] _门徽)
		{
			string sqlCommand = string.Format("UPDATE TBL_帮派数据 SET 门徽={1} WHERE ID='{0}'", 帮派id, Converter.ToString1(_门徽));
			DBA.ExeSqlCommand(sqlCommand);
		}

		public static byte[] 得到门徽(int id)
		{
			try
			{
				string sqlCommand = $"SELECT * FROM TBL_帮派数据 WHERE ID = {id}";
				DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand);
				if (dBToDataTable.Rows.Count == 0)
				{
					return null;
				}
				if (dBToDataTable.Rows[0]["门徽"].GetType().ToString() == "System.DBNull")
				{
					return null;
				}
				byte[] array = (byte[])dBToDataTable.Rows[0]["门徽"];
				if (array != null)
				{
					dBToDataTable.Dispose();
					return array;
				}
				return null;
			}
			catch (Exception value)
			{
				Console.WriteLine(value);
				return null;
			}
		}

		public static void PK记录(string UserId, string UserName, string ToUserId, string ToUserName)
		{
			if (World.PK记录 == 1)
			{
				string sql = "INSERT INTO TBL_PK记录 (UserId,UserName,ToUserId,ToUserName) VALUES (@UserId,@UserName,@ToUserId,@ToUserName)";
				SqlParameter[] prams = new SqlParameter[4]
				{
					SqlDBA.MakeInParam("@UserId", SqlDbType.VarChar, 30, UserId),
					SqlDBA.MakeInParam("@UserName", SqlDbType.VarChar, 30, UserName),
					SqlDBA.MakeInParam("@ToUserId", SqlDbType.VarChar, 30, ToUserId),
					SqlDBA.MakeInParam("@ToUserName", SqlDbType.VarChar, 30, ToUserName)
				};
				DbPoolClass dbPoolClass = new DbPoolClass();
				dbPoolClass.Conn = DBA.getstrConnection(null);
				dbPoolClass.Prams = prams;
				dbPoolClass.Sql = sql;
				dbPoolClass.Type = 1;
				World.SqlPool.Enqueue(dbPoolClass);
			}
		}

		public static bool 删除人物记录(string UserId, string UserName, string UserIp)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "PlayersBes_删除人物数据存储过程()");
			}
			try
			{
				string sqlCommand = "EXEC DELETE_USER_DATA @id, @name, @cip";
				SqlParameter[] prams = new SqlParameter[3]
				{
					SqlDBA.MakeInParam("@id", SqlDbType.VarChar, 20, UserId),
					SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 20, UserName),
					SqlDBA.MakeInParam("@cip", SqlDbType.VarChar, 20, UserIp)
				};
				if (DBA.ExeSqlCommand(sqlCommand, prams) != -1)
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "删除人物数据存储过程出错[" + UserId + "]-[" + UserName + "]" + ex.Message);
			}
			return false;
		}

		public static DataTable 得到传书列表(string name)
		{
			string sqlCommand = "SELECT top 10 * FROM TBL_传书系统 WHERE 接收人物名 =@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static void InitCoujiang()
		{
			chou_Jiang_Items = new List<Chou_jiang_item>();
			List<Chou_jiang_item> list = new List<Chou_jiang_item>();
			string sqlCommand = "Select * from [chou_jiang_item] where [Enable]=1";
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, "bbgDb");
			if (dBToDataTable != null)
			{
				if (dBToDataTable.Rows.Count == 0)
				{
					dBToDataTable.Dispose();
				}
				else
				{
					for (int i = 0; i < dBToDataTable.Rows.Count; i++)
					{
						Chou_jiang_item chou_jiang_item = new Chou_jiang_item();
						chou_jiang_item.id = (int)dBToDataTable.Rows[i]["id"];
						chou_jiang_item.ItemId = (long)dBToDataTable.Rows[i]["ItemId"];
						chou_jiang_item.Name = dBToDataTable.Rows[i]["Name"].ToString();
						chou_jiang_item.Probability = (int)dBToDataTable.Rows[i]["Probability"];
						chou_jiang_item.Index = (int)dBToDataTable.Rows[i]["Index"];
						list.Add(chou_jiang_item);
					}
					dBToDataTable.Dispose();
				}
			}
			Random random = new Random();
			foreach (Chou_jiang_item item in list)
			{
				for (int j = 0; j < item.Probability; j++)
				{
					chou_Jiang_Items.Add(new Chou_jiang_item
					{
						Num = random.Next(0, int.MaxValue),
						Probability = item.Probability,
						Enable = item.Enable,
						id = item.id,
						Index = item.Index,
						ItemId = item.ItemId,
						Name = item.Name
					});
				}
			}
			Form1.WriteLine(10, "抽奖配置读取完成，共" + list.Count.ToString() + "个奖品");
		}

		public static int 删除传书列表(string name)
		{
			try
			{
				string sqlCommand = "delete [TBL_传书系统] WHERE 接收人物名 ='" + name + "'";
				if (DBA.ExeSqlCommand(sqlCommand, "GameServer") != -1)
				{
					return 1;
				}
			}
			catch
			{
			}
			return -1;
		}

		public static void 设置传书已读(int id, int 是否已读)
		{
			string sqlCommand = "UPDATE TBL_传书系统 SET 阅读标识=@rd WHERE ID=@id";
			SqlParameter[] prams = new SqlParameter[2]
			{
				SqlDBA.MakeInParam("@rd", SqlDbType.Int, 0, 是否已读),
				SqlDBA.MakeInParam("@id", SqlDbType.Int, 30, id)
			};
			DBA.ExeSqlCommand(sqlCommand, prams);
		}

		public static void 创建传书(string fname, string sname, int npcid, string msg)
		{
			string sqlCommand = "EXEC INT_CS_DATA_New @fname, @sname, @msg, @npcid";
			SqlParameter[] prams = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@fname", SqlDbType.VarChar, 30, fname),
				SqlDBA.MakeInParam("@sname", SqlDbType.VarChar, 30, sname),
				SqlDBA.MakeInParam("@msg", SqlDbType.VarChar, 2000, msg),
				SqlDBA.MakeInParam("@npcid", SqlDbType.Int, 0, npcid)
			};
			DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static void 帮派赋予职位(int zw, string name)
		{
			string sqlCommand = "UPDATE TBL_帮派成员 SET Leve=@zw WHERE Name=@Username";
			SqlParameter[] prams = new SqlParameter[2]
			{
				SqlDBA.MakeInParam("@zw", SqlDbType.Int, 0, zw),
				SqlDBA.MakeInParam("@Username", SqlDbType.VarChar, 30, name)
			};
			DBA.ExeSqlCommand(sqlCommand, prams);
		}

		public static int 清除领奖标记()
		{
			string sqlCommand = "EXEC UPDATE_LQBZ";
			return (int)DBA.GetDBValue_3(sqlCommand);
		}

		public static int 创建帮派确认(string 帮派name)
		{
			string sqlCommand = "EXEC SELECT_Guild_DATA @bpnamea";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@bpnamea", SqlDbType.VarChar, 30, 帮派name)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static int 创建帮派(string name, string 帮派name, int leve)
		{
			string sqlCommand = "EXEC INT_Guild_DATA_New @name, @bpname,@leve";
			SqlParameter[] prams = new SqlParameter[3]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name),
				SqlDBA.MakeInParam("@bpname", SqlDbType.VarChar, 30, 帮派name),
				SqlDBA.MakeInParam("@leve", SqlDbType.Int, 6, leve)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static int 加入帮派(string name, string 帮派name, int leve)
		{
			string sqlCommand = string.Format("EXEC JR_Guild_DATA_New @name, @bpname,@leve", name, 帮派name, leve);
			SqlParameter[] prams = new SqlParameter[3]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name),
				SqlDBA.MakeInParam("@bpname", SqlDbType.VarChar, 30, 帮派name),
				SqlDBA.MakeInParam("@leve", SqlDbType.Int, 0, leve)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static int 退出门派(string name)
		{
			string sqlCommand = "EXEC Out_Guild_DATA @name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static int 逐出门派(string name, string 帮派name)
		{
			string sqlCommand = "EXEC OutBz_Guild_DATA @name, @bpname";
			SqlParameter[] prams = new SqlParameter[2]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name),
				SqlDBA.MakeInParam("@bpname", SqlDbType.VarChar, 30, 帮派name)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static int GetUserName(string name)
		{
			string sqlCommand = "SELECT FLD_NAME FROM TBL_人物数据 WHERE FLD_NAME=@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return -1;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				dBToDataTable.Dispose();
				return 1;
			}
			dBToDataTable.Dispose();
			return -1;
		}

		public static int CheckUserName(string name)
		{
			string sqlCommand = "SELECT FLD_NAME FROM TBL_人物数据 WHERE FLD_NAME=@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return -1;
			}
			if (dBToDataTable.Rows.Count == 1)
			{
				dBToDataTable.Dispose();
				return 1;
			}
			dBToDataTable.Dispose();
			return -1;
		}

		public static DataTable 得到帮派人数(string name)
		{
			string sqlCommand = "SELECT * FROM TBL_帮派成员 WHERE G_Name =@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static string 得到帮主名字(string name)
		{
			string result = "";
			DataTable dBToDataTable = DBA.GetDBToDataTable("SELECT * FROM TBL_帮派数据 WHERE G_Name = '" + name + "'");
			if (dBToDataTable != null && dBToDataTable.Rows.Count == 1)
			{
				result = dBToDataTable.Rows[0]["G_Master"].ToString();
			}
			return result;
		}

		public static DataTable 得到帮派数据(string name)
		{
			string sqlCommand = "SELECT * FROM TBL_帮派数据 WHERE G_Name = @name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static DataTable GetUserNameBp(string name)
		{
			string sqlCommand = "EXEC LOAD_Guild @name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static DataTable GetUserWarehouse(string Userid, string Username)
		{
			string sqlCommand = "select * from [TBL_个人仓库] where FLD_ID=@Userid and FLD_NAME =@Username";
			SqlParameter[] prams = new SqlParameter[2]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid),
				SqlDBA.MakeInParam("@Username", SqlDbType.VarChar, 30, Username)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count != 0)
			{
				return dBToDataTable;
			}
			string sqlCommand2 = "EXEC CREATE_USER_BANK @Userid,@Username,@aa,@zb";
			SqlParameter[] prams2 = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid),
				SqlDBA.MakeInParam("@Username", SqlDbType.VarChar, 30, Username),
				SqlDBA.MakeInParam("@aa", SqlDbType.Int, 0, 0),
				SqlDBA.MakeInParam("@zb", SqlDbType.VarBinary, 4380, new byte[4380])
			};
			DBA.ExeSqlCommand(sqlCommand2, prams2);
			string sqlCommand3 = "select * from [TBL_个人仓库] where FLD_ID=@Userid and FLD_NAME =@Username";
			SqlParameter[] prams3 = new SqlParameter[2]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid),
				SqlDBA.MakeInParam("@Username", SqlDbType.VarChar, 30, Username)
			};
			DataTable dBToDataTable2 = DBA.GetDBToDataTable(sqlCommand3, prams3);
			if (dBToDataTable2 == null)
			{
				return null;
			}
			if (dBToDataTable2.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable2;
		}

		public static DataTable GetUserPublicWarehouse(string Userid)
		{
			string sqlCommand = "select * from [TBL_综合仓库] where FLD_ID=@Userid";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count != 0)
			{
				return dBToDataTable;
			}
			Converter.ToString1(new byte[4380]);
			Converter.ToString1(new byte[50]);
			string sqlCommand2 = "EXEC CREATE_ID_BANK @Userid,@aaa,@ck,@ck1";
			SqlParameter[] prams2 = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid),
				SqlDBA.MakeInParam("@aaa", SqlDbType.Int, 0, 0),
				SqlDBA.MakeInParam("@ck", SqlDbType.VarBinary, 4380, new byte[4380]),
				SqlDBA.MakeInParam("@ck1", SqlDbType.VarBinary, 50, new byte[50])
			};
			DBA.ExeSqlCommand(sqlCommand2, prams2);
			string sqlCommand3 = "select * from [TBL_综合仓库] where FLD_ID='" + Userid + "'";
			SqlParameter[] prams3 = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid)
			};
			DataTable dBToDataTable2 = DBA.GetDBToDataTable(sqlCommand3, prams3);
			if (dBToDataTable2 == null)
			{
				return null;
			}
			if (dBToDataTable2.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable2;
		}

		public static long smethod_0()
		{
			return ItmeId.AcquireBuffer();
		}

		public static int SetUserName(string id, string name, int zy, byte[] coue, string fqid)
		{
			byte[] array = new byte[73];
			byte[] array2 = new byte[1095];
			byte[] array3 = new byte[2628];
			byte[] bytes = BitConverter.GetBytes(GetDBItmeId());
			byte[] src = new byte[4];
			byte[] array4 = new byte[4];
			array4 = BitConverter.GetBytes(1);
			switch (zy)
			{
			case 1:
				src = BitConverter.GetBytes(100200002);
				break;
			case 2:
				src = BitConverter.GetBytes(200200002);
				break;
			case 3:
				src = BitConverter.GetBytes(300200002);
				break;
			case 4:
				src = BitConverter.GetBytes(400200002);
				break;
			case 5:
				src = BitConverter.GetBytes(500200002);
				break;
			}
			Buffer.BlockCopy(bytes, 0, array, 0, 4);
			Buffer.BlockCopy(src, 0, array, 8, 4);
			Buffer.BlockCopy(array4, 0, array, 12, 4);
			Buffer.BlockCopy(array, 0, array3, 0, 73);
			if (World.是否上线发送礼品 == 1)
			{
				byte[] array5 = new byte[37];
				byte[] bytes2 = BitConverter.GetBytes(smethod_0());
				byte[] bytes3 = BitConverter.GetBytes(World.上线礼品标识码);
				Buffer.BlockCopy(bytes2, 0, array5, 0, 4);
				Buffer.BlockCopy(bytes3, 0, array5, 8, 4);
				Buffer.BlockCopy(array4, 0, array5, 12, 4);
				Buffer.BlockCopy(array5, 0, array3, 37, 37);
			}
			int num = 0;
			for (int i = 0; i < 4; i++)
			{
				string sqlCommand = "Select FLD_INDEX FROM TBL_人物数据 Where FLD_ID=@FLD_ID and FLD_INDEX=@INDEX";
				SqlParameter[] prams = new SqlParameter[2]
				{
					SqlDBA.MakeInParam("@INDEX", SqlDbType.Int, 0, i),
					SqlDBA.MakeInParam("@FLD_ID", SqlDbType.VarChar, 30, id)
				};
				DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
				if (dBToDataTable.Rows.Count == 0)
				{
					num = i;
					dBToDataTable.Dispose();
					break;
				}
				dBToDataTable.Dispose();
			}
			string sqlCommand2 = "Select FLD_INDEX FROM TBL_人物数据 Where FLD_ID=@FLD_ID";
			SqlParameter[] prams2 = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@FLD_ID", SqlDbType.VarChar, 30, id)
			};
			DataTable dBToDataTable2 = DBA.GetDBToDataTable(sqlCommand2, prams2);
			if (dBToDataTable2.Rows.Count >= 4)
			{
				dBToDataTable2.Dispose();
				return -1;
			}
			dBToDataTable2.Dispose();
			string sqlCommand3 = "EXEC INT_USER_DATA @FLD_ID,@name,@rwid,@zy,@fqid,@coue,@xrwhex,@xrwhex2";
			SqlParameter[] prams3 = new SqlParameter[8]
			{
				SqlDBA.MakeInParam("@FLD_ID", SqlDbType.VarChar, 30, id),
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name),
				SqlDBA.MakeInParam("@rwid", SqlDbType.Int, 0, num),
				SqlDBA.MakeInParam("@zy", SqlDbType.Int, 0, zy),
				SqlDBA.MakeInParam("@fqid", SqlDbType.VarChar, 30, fqid),
				SqlDBA.MakeInParam("@coue", SqlDbType.VarBinary, 10, coue),
				SqlDBA.MakeInParam("@xrwhex", SqlDbType.VarBinary, array2.Length, array2),
				SqlDBA.MakeInParam("@xrwhex2", SqlDbType.VarBinary, array3.Length, array3)
			};
			if (DBA.ExeSqlCommand(sqlCommand3, prams3) != -1)
			{
				return 1;
			}
			return -1;
		}

		public static int SetUserNameA(string id, string name, int zy, byte[] coue, int ChessUid)
		{
			byte[] array = new byte[World.物品数据];
			byte[] array2 = new byte[15 * World.物品数据];
			byte[] array3 = new byte[36 * World.物品数据];
			byte[] bytes = BitConverter.GetBytes(GetDBItmeId());
			byte[] src = new byte[4];
			byte[] bytes2 = BitConverter.GetBytes(1);
			switch (zy)
			{
			case 1:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 2:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 3:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 4:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 5:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 6:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			case 7:
				src = BitConverter.GetBytes(World.新手上线礼包);
				break;
			}
			Buffer.BlockCopy(bytes, 0, array, 0, 4);
			Buffer.BlockCopy(src, 0, array, 8, 4);
			Buffer.BlockCopy(bytes2, 0, array, 12, 4);
			Buffer.BlockCopy(array, 0, array3, 0, World.物品数据);
			int num = 0;
			DataTable dataTable = 得到人物数据ID(id);
			bool flag = false;
			if (dataTable == null)
			{
				flag = true;
				num = 0;
			}
			else
			{
				if (dataTable.Rows.Count >= 4)
				{
					dataTable.Dispose();
					return -1;
				}
				List<int> list = new List<int>();
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					int item = (int)dataTable.Rows[i]["FLD_INDEX"];
					list.Add(item);
				}
				for (int j = 0; j < 4; j++)
				{
					if (!list.Contains(j))
					{
						num = j;
						break;
					}
				}
				dataTable.Dispose();
			}
			if (DBA.ExeSqlCommand("EXEC INT_USER_DATA @FLD_ID, @name, @rwid, @zy, @fqid, @coue, @xrwhex, @xrwhex2", new SqlParameter[8]
			{
				SqlDBA.MakeInParam("@FLD_ID", SqlDbType.VarChar, 20, id),
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 20, name),
				SqlDBA.MakeInParam("@rwid", SqlDbType.Int, 0, num),
				SqlDBA.MakeInParam("@zy", SqlDbType.Int, 0, zy),
				SqlDBA.MakeInParam("@fqid", SqlDbType.VarChar, 20, ChessUid.ToString()),
				SqlDBA.MakeInParam("@coue", SqlDbType.VarBinary, 10, coue),
				SqlDBA.MakeInParam("@xrwhex", SqlDbType.VarBinary, array2.Length, array2),
				SqlDBA.MakeInParam("@xrwhex2", SqlDbType.VarBinary, array3.Length, array3)
			}) == -1)
			{
				return -1;
			}
			CreateUserBank(id, name);
			if (flag)
			{
				CreateIDBank(id);
			}
			return 1;
		}

		public static string 获取注册地址(string UserId)
		{
			string result = "127.0.0.1";
			string sqlCommand = "select FLD_REGIP from [TBL_ACCOUNT] where FLD_ID='" + UserId + "'";
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, "rxjhaccount");
			if (dBToDataTable != null && dBToDataTable.Rows.Count > 0)
			{
				result = dBToDataTable.Rows[0]["FLD_REGIP"].ToString();
			}
			return result;
		}

		public static DataTable 得到人物数据ID(string Userid)
		{
			DataTable dataTable = SqlDBA.RunProcc(new SqlConnection(DBA.getstrConnection(null)), "LOAD_CHARS", new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.VarChar, 30, Userid)
			});
			if (dataTable != null)
			{
				if (dataTable.Rows.Count > 0)
				{
					return dataTable;
				}
				dataTable.Dispose();
			}
			return null;
		}

		public static void CreateIDBank(string Userid)
		{
			SqlDBA.RunProc(new SqlConnection(DBA.getstrConnection(null)), "CREATE_ID_BANK", new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.VarChar, 50, Userid),
				SqlDBA.MakeInParam("@money", SqlDbType.VarChar, 50, "0"),
				SqlDBA.MakeInParam("@strItem", SqlDbType.VarBinary, 4380, new byte[4380]),
				SqlDBA.MakeInParam("@strItime", SqlDbType.VarBinary, 50, new byte[50])
			});
		}

		public static void CreateUserBank(string Userid, string Username)
		{
			SqlDBA.RunProc(new SqlConnection(DBA.getstrConnection(null)), "CREATE_USER_BANK", new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.VarChar, 50, Userid),
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 50, Username),
				SqlDBA.MakeInParam("@money", SqlDbType.VarChar, 50, "0"),
				SqlDBA.MakeInParam("@strItem", SqlDbType.VarBinary, 4380, new byte[4380])
			});
		}

		public static int GetCwUserName(string name, string zrname, int type, long id)
		{
			string sqlCommand = "SELECT Name FROM TBL_宠物数据 WHERE Name=@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 20, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return -1;
			}
			if (dBToDataTable.Rows.Count != 0)
			{
				dBToDataTable.Dispose();
				return -1;
			}
			dBToDataTable.Dispose();
			string sqlCommand2 = "EXEC INT_Cw_DATA @ZrName, @Name, @ItmeId, @FLD_JOB, @strWearitem, @strItem";
			SqlParameter[] prams2 = new SqlParameter[6]
			{
				SqlDBA.MakeInParam("@ZrName", SqlDbType.VarChar, 20, zrname),
				SqlDBA.MakeInParam("@Name", SqlDbType.VarChar, 20, name),
				SqlDBA.MakeInParam("@ItmeId", SqlDbType.Int, 0, id),
				SqlDBA.MakeInParam("@FLD_JOB", SqlDbType.Int, 0, type),
				SqlDBA.MakeInParam("@strWearitem", SqlDbType.VarBinary, 292, new byte[292]),
				SqlDBA.MakeInParam("@strItem", SqlDbType.VarBinary, 1168, new byte[1168])
			};
			if (DBA.ExeSqlCommand(sqlCommand2, prams2) != -1)
			{
				return 1;
			}
			return -1;
		}

		public static bool 增加元宝(string id, int point)
		{
			if (DBA.GetDBToDataTable("select * from [TBL_ACCOUNT] where FLD_ID='" + id + "'", "rxjhaccount") == null)
			{
				return false;
			}
			string sqlCommand = string.Format("update [TBL_ACCOUNT] SET FLD_RXPIONT=FLD_RXPIONT + '{1}' WHERE FLD_ID ='{0}'", id, point);
			return DBA.ExeSqlCommand(sqlCommand, "rxjhaccount") != -1;
		}

		public static int GetCwDead(long id)
		{
			int result = 0;
			string sqlCommand = string.Format("SELECT FLD_SW FROM TBL_宠物数据 WHERE Itmeid=@id", id);
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.Int, 30, id)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable != null)
			{
				if (dBToDataTable.Rows.Count != 0)
				{
					result = (int)dBToDataTable.Rows[0]["FLD_SW"];
					dBToDataTable.Dispose();
				}
				else
				{
					dBToDataTable.Dispose();
				}
			}
			return result;
		}

		public static int GetCwJobLevel(long id)
		{
			int result = 0;
			string sqlCommand = string.Format("SELECT FLD_JOB_LEVEL FROM TBL_宠物数据 WHERE Itmeid=@id", id);
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@id", SqlDbType.Int, 30, id)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable != null)
			{
				if (dBToDataTable.Rows.Count != 0)
				{
					result = (int)dBToDataTable.Rows[0]["FLD_JOB_LEVEL"];
					dBToDataTable.Dispose();
				}
				else
				{
					dBToDataTable.Dispose();
				}
			}
			return result;
		}

		public static bool SetCwDead(long id)
		{
			string sqlCommand = $"UPDATE TBL_宠物数据 SET FLD_SW=0,FLD_HP=100 WHERE Itmeid={id}";
			return DBA.ExeSqlCommand(sqlCommand, "GameServer") != -1;
		}

		public static DataTable 得到师傅数据(string name)
		{
			string sqlCommand = "SELECT * FROM TBL_师徒数据 WHERE FLD_TNAME =@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static DataTable 得到徒弟数据(string name)
		{
			string sqlCommand = "SELECT * FROM TBL_师徒数据 WHERE FLD_SNAME =@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, name)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static int 创建师徒关系(string 徒弟, string 师傅, int tlevel, int index)
		{
			string sqlCommand = string.Format("SELECT FLD_TNAME FROM TBL_师徒数据 WHERE FLD_TNAME=@name", 徒弟);
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.VarChar, 30, 徒弟)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return -1;
			}
			if (dBToDataTable.Rows.Count != 0)
			{
				dBToDataTable.Dispose();
				return -1;
			}
			dBToDataTable.Dispose();
			string sqlCommand2 = string.Format("EXEC INT_St_DATA @sname,@tname,@tlevel,@index", 师傅, 徒弟, tlevel, index);
			SqlParameter[] prams2 = new SqlParameter[4]
			{
				SqlDBA.MakeInParam("@sname", SqlDbType.VarChar, 30, 师傅),
				SqlDBA.MakeInParam("@tname", SqlDbType.VarChar, 30, 徒弟),
				SqlDBA.MakeInParam("@tlevel", SqlDbType.Int, 0, tlevel),
				SqlDBA.MakeInParam("@index", SqlDbType.Int, 0, index)
			};
			if (DBA.ExeSqlCommand(sqlCommand2, prams2) != -1)
			{
				return 1;
			}
			return -1;
		}

		public static int 解除师徒关系(string 徒弟, string 师傅)
		{
			string sqlCommand = "delete [TBL_师徒数据] WHERE FLD_TNAME ='" + 徒弟 + "' and FLD_SNAME='" + 师傅 + "'";
			if (DBA.ExeSqlCommand(sqlCommand, "GameServer") != -1)
			{
				return 1;
			}
			return -1;
		}

		public static int 换名符确认(string Userid, string UserName, string sTemp)
		{
			string sqlCommand = "EXEC PROC_USER_RENAME @Userid,@Username,@sTemp";
			SqlParameter[] prams = new SqlParameter[3]
			{
				SqlDBA.MakeInParam("@Userid", SqlDbType.VarChar, 30, Userid),
				SqlDBA.MakeInParam("@Username", SqlDbType.VarChar, 30, UserName),
				SqlDBA.MakeInParam("@sTemp", SqlDbType.VarChar, 30, sTemp)
			};
			return (int)DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static void 初始化副本次数()
		{
			string sqlCommand = "EXEC INT_FB_DATA_New";
			SqlParameter[] prams = null;
			DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static void 初始化BOSS次数()
		{
			string sqlCommand = "EXEC INT_BOSS_DATA_New";
			SqlParameter[] prams = null;
			DBA.GetDBValue_3(sqlCommand, prams);
		}

		public static DataTable 得到宠物数据(long itemid)
		{
			string sqlCommand = "SELECT * FROM TBL_宠物数据 WHERE ItmeId =@name";
			SqlParameter[] prams = new SqlParameter[1]
			{
				SqlDBA.MakeInParam("@name", SqlDbType.BigInt, 0, itemid)
			};
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, prams);
			if (dBToDataTable == null)
			{
				return null;
			}
			if (dBToDataTable.Rows.Count == 0)
			{
				return null;
			}
			return dBToDataTable;
		}

		public static int 寄售元宝(string UserId, int 元宝数)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat("UPDATE [TBL_ACCOUNT] SET FLD_RXPIONT = FLD_RXPIONT + {1} WHERE FLD_ID = '{0}'", UserId, 元宝数);
			return DBA.ExeSqlCommand(stringBuilder.ToString(), "rxjhaccount");
		}

		public static int 寄售物品(寄存物品类 物品)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat("INSERT INTO PLAYITEM (FLD_PID,FLD_NAME,FLD_PRICE,FLD_DESC,FLD_TYPE,FLD_MAGIC0,FLD_MAGIC1,FLD_MAGIC2,FLD_MAGIC3,FLD_MAGIC4,FLD_绑定,FLD_PlayID,FLD_PlayName,ID) VALUES ({0},'{1}',{2},'{3}',{4},{5},{6},{7},{8},{9},{10},'{11}','{12}',{13})", 物品.PID, 物品.NAME, 物品.PRICE, 物品.DESC, 物品.TYPE, 物品.MAGIC0, 物品.MAGIC1, 物品.MAGIC2, 物品.MAGIC3, 物品.MAGIC4, 物品.绑定, 物品.PlayID, 物品.PlayName, 物品.ID);
			return DBA.ExeSqlCommand(stringBuilder.ToString(), "bbgDb");
		}

		public static int 取消寄售(long id)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat("DELETE PLAYITEM WHERE ID = {0}", id);
			return DBA.ExeSqlCommand(stringBuilder.ToString(), "bbgDb");
		}

		public static int 变更寄售类型(int id, int lx)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat("UPDATE PLAYITEM SET FLD_TYPE = {1} WHERE ID = {0}", id, lx);
			return DBA.ExeSqlCommand(stringBuilder.ToString(), "bbgDb");
		}

		public static int 变更寄售时间(int id)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendFormat("UPDATE PLAYITEM SET FLD_TIME = '{1}' WHERE ID = {0}", id, DateTime.Now);
			return DBA.ExeSqlCommand(stringBuilder.ToString(), "bbgDb");
		}

		public static int 得到寄售Key()
		{
			string sqlCommand = "Select TOP 1 * from [PLAYITEM] Order By ID";
			DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, "bbgDb");
			if (dBToDataTable != null)
			{
				return (int)dBToDataTable.Rows[0]["ID"];
			}
			return 0;
		}

		public static int 得到寄售数量(string id)
		{
			string sqlCommand = "Select * from [PLAYITEM] where FLD_TYPE = 1 AND FLD_PLAYID = '" + id + "' ";
			return DBA.GetDBToDataTable(sqlCommand, "bbgDb")?.Rows.Count ?? 0;
		}

		public static 寄存物品类 得到寄售物品(int 全局ID)
		{
			try
			{
				string sqlCommand = $"Select * from [PLAYITEM] where FLD_TYPE = 1 AND ID = {全局ID}";
				DataTable dBToDataTable = DBA.GetDBToDataTable(sqlCommand, "bbgDb");
				if (dBToDataTable != null)
				{
					if (dBToDataTable.Rows.Count == 0)
					{
						dBToDataTable.Dispose();
					}
					else
					{
						if (dBToDataTable.Rows.Count <= 1)
						{
							寄存物品类 寄存物品类 = new 寄存物品类();
							寄存物品类.ID = (long)dBToDataTable.Rows[0]["ID"];
							寄存物品类.PID = (int)dBToDataTable.Rows[0]["FLD_PID"];
							寄存物品类.NAME = dBToDataTable.Rows[0]["FLD_NAME"].ToString();
							寄存物品类.PRICE = (int)dBToDataTable.Rows[0]["FLD_PRICE"];
							寄存物品类.DESC = dBToDataTable.Rows[0]["FLD_DESC"].ToString();
							寄存物品类.TYPE = (int)dBToDataTable.Rows[0]["FLD_TYPE"];
							寄存物品类.MAGIC0 = (int)dBToDataTable.Rows[0]["FLD_MAGIC0"];
							寄存物品类.MAGIC1 = (int)dBToDataTable.Rows[0]["FLD_MAGIC1"];
							寄存物品类.MAGIC2 = (int)dBToDataTable.Rows[0]["FLD_MAGIC2"];
							寄存物品类.MAGIC3 = (int)dBToDataTable.Rows[0]["FLD_MAGIC3"];
							寄存物品类.MAGIC4 = (int)dBToDataTable.Rows[0]["FLD_MAGIC4"];
							寄存物品类.绑定 = (int)dBToDataTable.Rows[0]["FLD_绑定"];
							寄存物品类.PlayID = dBToDataTable.Rows[0]["FLD_PlayID"].ToString();
							寄存物品类.PlayName = dBToDataTable.Rows[0]["FLD_PlayName"].ToString();
							寄存物品类.时间 = DateTime.Parse(dBToDataTable.Rows[0]["FLD_TIME"].ToString());
							dBToDataTable.Dispose();
							return 寄存物品类;
						}
						logo.寄售记录("得到寄售物品()出错 存在重复全局ID - " + ((int)dBToDataTable.Rows[0]["ID"]).ToString());
						dBToDataTable.Dispose();
					}
				}
			}
			catch (Exception ex)
			{
				string message = ex.Message;
			}
			return null;
		}
	}
}
